package com.cloudbroker.openapi.manage.controller;

import com.cloudbroker.bcs.platform.ltb.bizapi.service.coupon.vo.*;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.coupon.back.*;

import com.cloudbroker.bcs.platform.ltb.bizapi.t2service.coupon.CouponT2BizService;
import org.springframework.beans.factory.annotation.Autowired;
import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.transaction.back.*;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.transaction.vo.*;
import org.springframework.web.bind.annotation.*;
import com.cloudbroker.bcs.platform.ltb.common.ext.annotation.SaveLog;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import static com.cloudbroker.bcs.platform.ltb.common.util.RequestUtil.getSingleParameterMapForBody;
import java.util.List;

/*
 * 模块名称：Coupon
 * by xuss13891
 */

@Controller
public class CouponController {

	@Resource
	private CouponT2BizService couponT2BizService;

	// 库存优惠券新增(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_stock_add")
	@SaveLog(remark = "库存优惠券新增(管理)")
	public CouponStockAddBack couponStockAdd(HttpServletRequest request,@RequestParam(value="target_users[]",required=false) List<Long> targetUsers,@RequestParam(value="target_activities[]",required=false) List<Long> targetActivities,@RequestParam(value="target_goods[]",required=false) List<Long> targetGoods, String jsonpcallback){
		CouponStockAddVO vo = getSingleParameterMapForBody(request, CouponStockAddVO.class);
		vo.setTarget_users(targetUsers);
		vo.setTarget_activities(targetActivities);
		vo.setTarget_goods(targetGoods);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponStockAdd(vo), jsonpcallback);
	}

	// 库存优惠券停用(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_stock_stop")
	@SaveLog(remark = "库存优惠券停用(管理)")
	public HSBCPSBackVO couponStockStop(HttpServletRequest request, String jsonpcallback){
		CouponStockStopVO vo = getSingleParameterMapForBody(request, CouponStockStopVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponStockStop(vo), jsonpcallback);
	}

	// 库存优惠券修改(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_stock_mod")
	@SaveLog(remark = "库存优惠券修改(管理)")
	public HSBCPSBackVO couponStockMod(HttpServletRequest request,@RequestParam(value="target_users[]",required=false) List<Long> targetUsers,@RequestParam(value="target_activities[]",required=false) List<Long> targetActivities,@RequestParam(value="target_goods[]",required=false) List<Long> targetGoods, String jsonpcallback){
		CouponStockModVO vo = getSingleParameterMapForBody(request, CouponStockModVO.class);
		vo.setTarget_users(targetUsers);
		vo.setTarget_activities(targetActivities);
		vo.setTarget_goods(targetGoods);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponStockMod(vo), jsonpcallback);
	}

	// 库存优惠券删除(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_stock_del")
	@SaveLog(remark = "库存优惠券删除(管理)")
	public HSBCPSBackVO couponStockDel(HttpServletRequest request, String jsonpcallback){
		CouponStockDelVO vo = getSingleParameterMapForBody(request, CouponStockDelVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponStockDel(vo), jsonpcallback);
	}

	// 库存优惠券查询(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_stock_qry")
	@SaveLog(remark = "库存优惠券查询(管理)")
	public CouponStockQryBack couponStockQry(HttpServletRequest request, String jsonpcallback){
		CouponStockQryVO vo = getSingleParameterMapForBody(request, CouponStockQryVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponStockQry(vo), jsonpcallback);
	}

	// 活动与优惠券绑定(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_activity_bind")
	@SaveLog(remark = "活动与优惠券绑定(管理)")
	public HSBCPSBackVO couponActivityBind(HttpServletRequest request,@RequestParam(value="activity_ids[]",required=false) List<Long> activityIds, String jsonpcallback){
		CouponActivityBindVO vo = getSingleParameterMapForBody(request, CouponActivityBindVO.class);
		vo.setActivity_ids(activityIds);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponActivityBind(vo), jsonpcallback);
	}

	// 活动与优惠券解绑(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_activity_unbind")
	@SaveLog(remark = "活动与优惠券解绑(管理)")
	public HSBCPSBackVO couponActivityUnbind(HttpServletRequest request,@RequestParam(value="activity_ids[]",required=false) List<Long> activityIds, String jsonpcallback){
		CouponActivityUnbindVO vo = getSingleParameterMapForBody(request, CouponActivityUnbindVO.class);
		vo.setActivity_ids(activityIds);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponActivityUnbind(vo), jsonpcallback);
	}

	// 商品与优惠券绑定(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_goods_bind")
	@SaveLog(remark = "商品与优惠券绑定(管理)")
	public HSBCPSBackVO couponGoodsBind(HttpServletRequest request,@RequestParam(value="goods_ids[]",required=false) List<Long> goodsIds, String jsonpcallback){
		CouponGoodsBindVO vo = getSingleParameterMapForBody(request, CouponGoodsBindVO.class);
		vo.setGoods_ids(goodsIds);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponGoodsBind(vo), jsonpcallback);
	}

	// 商品与优惠券解绑(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_goods_unbind")
	@SaveLog(remark = "商品与优惠券解绑(管理)")
	public HSBCPSBackVO couponGoodsUnbind(HttpServletRequest request,@RequestParam(value="goods_ids[]",required=false) List<Long> goodsIds, String jsonpcallback){
		CouponGoodsUnbindVO vo = getSingleParameterMapForBody(request, CouponGoodsUnbindVO.class);
		vo.setGoods_ids(goodsIds);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponGoodsUnbind(vo), jsonpcallback);
	}

	// 优惠券活动发放
	@ResponseBody
	@RequestMapping("/coupon_activity_give")
	@SaveLog(remark = "优惠券活动发放")
	public CouponActivityGiveBack couponActivityGive(HttpServletRequest request, String jsonpcallback){
		CouponActivityGiveVO vo = getSingleParameterMapForBody(request, CouponActivityGiveVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponActivityGive(vo), jsonpcallback);
	}

	// 优惠券活动发放(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_activity_give")
	@SaveLog(remark = "优惠券活动发放(管理)")
	public CouponActivityGiveBack couponActivityGiveManage(HttpServletRequest request, String jsonpcallback){
		CouponActivityGiveVO vo = getSingleParameterMapForBody(request, CouponActivityGiveVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponActivityGiveManage(vo), jsonpcallback);
	}

	// 优惠券运营发放/积分兑换
	@ResponseBody
	@RequestMapping("/coupon_give")
	@SaveLog(remark = "优惠券运营发放/积分兑换")
	public CouponGiveBack couponGive(HttpServletRequest request, String jsonpcallback){
		CouponGiveVO vo = getSingleParameterMapForBody(request, CouponGiveVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponGive(vo), jsonpcallback);
	}

	// 优惠券运营发放/积分兑换(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_give")
	@SaveLog(remark = "优惠券运营发放/积分兑换(管理)")
	public CouponGiveBack couponGiveManage(HttpServletRequest request, String jsonpcallback){
		CouponGiveVO vo = getSingleParameterMapForBody(request, CouponGiveVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponGiveManage(vo), jsonpcallback);
	}

	// 用户优惠券查询
	@ResponseBody
	@RequestMapping("/coupon_user_qry")
	@SaveLog(remark = "用户优惠券查询")
	public CouponUserQryBack couponUserQry(HttpServletRequest request, String jsonpcallback){
		CouponUserQryVO vo = getSingleParameterMapForBody(request, CouponUserQryVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponUserQry(vo), jsonpcallback);
	}

	// 用户优惠券查询(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_user_qry")
	@SaveLog(remark = "用户优惠券查询(管理)")
	public CouponUserQryBack couponUserQryManage(HttpServletRequest request, String jsonpcallback){
		CouponUserQryVO vo = getSingleParameterMapForBody(request, CouponUserQryVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponUserQryManage(vo), jsonpcallback);
	}

	// 优惠券使用预览
	@ResponseBody
	@RequestMapping("/coupon_use_preview")
	@SaveLog(remark = "优惠券使用预览")
	public CouponUsePreviewBack couponUsePreview(HttpServletRequest request, String jsonpcallback){
		CouponUsePreviewVO vo = getSingleParameterMapForBody(request, CouponUsePreviewVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponUsePreview(vo), jsonpcallback);
	}

	// 优惠券使用确认
	@ResponseBody
	@RequestMapping("/coupon_use_confirm")
	@SaveLog(remark = "优惠券使用确认")
	public HSBCPSBackVO couponUseConfirm(HttpServletRequest request, String jsonpcallback){
		CouponUseConfirmVO vo = getSingleParameterMapForBody(request, CouponUseConfirmVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponUseConfirm(vo), jsonpcallback);
	}

	// 优惠券使用取消
	@ResponseBody
	@RequestMapping("/coupon_use_cancel")
	@SaveLog(remark = "优惠券使用取消")
	public HSBCPSBackVO couponUseCancel(HttpServletRequest request, String jsonpcallback){
		CouponUseCancelVO vo = getSingleParameterMapForBody(request, CouponUseCancelVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponUseCancel(vo), jsonpcallback);
	}

	// 优惠券流水查询
	@ResponseBody
	@RequestMapping("/coupon_journal_qry")
	@SaveLog(remark = "优惠券流水查询")
	public CouponJournalQryBack couponJournalQry(HttpServletRequest request, String jsonpcallback){
		CouponJournalQryVO vo = getSingleParameterMapForBody(request, CouponJournalQryVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponJournalQry(vo), jsonpcallback);
	}

	// 优惠券流水查询(管理接口)
	@ResponseBody
	@RequestMapping("/manage/coupon_journal_qry")
	@SaveLog(remark = "优惠券流水查询(管理)")
	public CouponJournalQryBack couponJournalQryManage(HttpServletRequest request, String jsonpcallback){
		CouponJournalQryVO vo = getSingleParameterMapForBody(request, CouponJournalQryVO.class);
		return VOUtil.setJsonpResult(couponT2BizService.funcCouponJournalQryManage(vo), jsonpcallback);
	}

}
